package com.manager.config;

import com.manager.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MywebConfigure implements WebMvcConfigurer {

    @Resource
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/student/**");
        registry.addInterceptor(loginInterceptor).addPathPatterns("/manager/**");
        registry.addInterceptor(loginInterceptor).addPathPatterns("/admin/**");
        //若不需要拦截的页面 直接使用.excludePathPatterns()排除不需要拦截的路径
    }
}
